Fix that ViFindBrace doesn't search for brace when current char is not a brace#4862
Fix that ViFindBrace doesn't search for brace when current char is not a brace#4862sharpchen wants to merge 2 commits intoPowerShell:masterfrom
Conversation
|
S |
|
You are right that's how it works. I'm hoping we can do two things: verify the order of precedence in vanilla Vi (I was playing around trying to determine it and couldn't make heads or tails of it), and add some unit tests. Thanks! Love the fix though. |
Not sure what it means? If you mean the standard behavior,
And
It indeed requires some tests. I did find at least one inconsistent behavior. |
|
Hi @andyleejordan. I've rewrote the implementation, I think it's now good to go. |
| // find next of any kind of paren | ||
| for (; nextParen < _buffer.Length; nextParen++) | ||
| for (int idx = 0; idx < parenthese.Length; idx++) | ||
| if (parenthese[idx] == _buffer[nextParen]) goto Outer; |
There was a problem hiding this comment.
The rare great use of goto
|
I'm not sure but if this build is like others (looking at PSScriptAnalyzer right now), AppVeyor is at least running tests, looks like |
611243c to
fee3566
Compare
|
Looks like tests are only available on Windows.
I honestly have no idea why test's failing. There's is a input but claims no key. |
I forgot about that but yes this is unfortunately true. |
|
@sharpchen I will get this built on Windows and see if I can't fix the test so we can get this in! |
|
Claude Opus 4.6 was actualy very adapt at fixing this error (it helps that the test was failing for the same reason as other similar tests, which then already had a fix it applied). |
These tests need to be cleared with `ddi` and then asserted to be empty. It's the same fix for the other tests whose input contains unmatched braces. Copilot's plausible explanation is that the unmatched braces cause the input to be flagged by PowerShell's parser as incomplete, so `AcceptLineImpl` instead waits for more input, causing the exception.
48bf1d5 to
85ec2c2
Compare
PR Summary
Vi searches right pair of first left brace, or first right brace when current char is not a brace. This pr added this functionality.
After the update,

ViGotoBraceshould work like this(of course this will also affect other methods such asViDeleteBrace):PR Checklist
Microsoft Reviewers: Open in CodeFlow